"""任务页面"""
from selenium.webdriver.common.by import By
from page.base_page import BasePage
class TaskPage(BasePage):
    """数据准备"""
    url="/index.php?m=task"
    my_task_locator=(By.LINK_TEXT,"我的任务")
    click_add_task_locator = (By.LINK_TEXT, "新建任务")
    accounts_receivable_name_locator=(By.CSS_SELECTOR,"body > div.container > div.alert.alert-success")
    click_two_locator = (By.CSS_SELECTOR,"#form1 > table > tfoot > tr > td > div.pagination > div.span4 > div > ul > li:nth-child(3) > a")
    click_home_locator = (By.CSS_SELECTOR,"#form1 > table > tfoot > tr > td > div.pagination > div.span4 > div > ul > li:nth-child(1) > a")
    clean_up_the_environment_locator = (By.CSS_SELECTOR,"#form1 > table > tbody > tr:nth-child(1) > td:nth-child(1) > input")
    delet_locator = (By.ID, "delete")
    def my_task_text(self):
        """返回任务页面的我的任务"""
        return self.find_element(self.my_task_locator).text
    def click_add_task(self):
        """点击新建任务"""
        self.click(self.click_add_task_locator)
    def accounts_receivable_name(self):
        """返回添加成功内容"""
        return self.find_element(self.accounts_receivable_name_locator).text
    def click_two(self):
        """点击第二页"""
        self.click(self.click_two_locator)
    def  click_home(self):
        """点击首页"""
        self.click(self.click_two_locator)
    def click_one_data(self):
        """选择第一条数据"""
        self.click(self.clean_up_the_environment_locator)
    def click_delete(self):
        """点击删除"""
        self.click(self.delet_locator)
    def click_sure(self):
        """弹出弹窗点击确定"""
        self.driver.switch_to.alert.accept()